package com.yc.jpyy.discre.service.impl;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import com.yc.jpyy.base.service.BaseService;
import com.yc.jpyy.base.util.PageBean;
import com.yc.jpyy.discre.dao.DiscreDao;
import com.yc.jpyy.discre.service.DiscreService;


@Service
public class DiscreServiceImpl extends BaseService implements DiscreService {
    
	@Autowired
	private DiscreDao discreDao;

	

	@Override
	public int addDiscreService(Map<String, Object> paramsMap) throws DataAccessException {
		int ret = discreDao.addDiscreDao(paramsMap);
		System.out.println(ret);
		return ret;
	}

	@Override
	public int updateDiscreService(Map<String, Object> paramsMap) throws DataAccessException {
		int ret = discreDao.updateDiscreDao(paramsMap);
		return ret;
		
	}

	
	
	

	@Override
	public Map<String, Object> findDiscreByIDServer(Map<String, Object> paramsMap) throws DataAccessException {
	     return discreDao.findDiscreByIdDao(paramsMap);
	}

	

	@Override
	public PageBean findDiscreService(Map<String, Object> paramsMap) throws DataAccessException {
		int pagenum = Integer.parseInt(paramsMap.get("pagenum").toString());
		int pagesize = Integer.parseInt(paramsMap.get("pagesize").toString());
		paramsMap.put("pagestart", (pagenum-1) * pagesize);
		List list = discreDao.findDiscreDao(paramsMap);
		PageBean pageBean = new PageBean();
		pageBean.setList(list);
		// 每页几条数据，默认20条
		pageBean.setPageSize(pagesize);
		// 得到数据库中的条数
		pageBean.setAllRow(this.findCountDiscreService(paramsMap));
		// 当前第几页，默认第一页
		pageBean.setCurrentPage(pagenum);
		// 得到一共几页
		pageBean.setTotalPage(pageBean.getTotalPage());
		// 模仿百度分页，只显示10条数据
		pageBean.paginationTool(pagenum, pageBean.getTotalPage());
		return pageBean;
	}

	@Override
	public int findCountDiscreService(Map<String, Object> paramsMap) throws DataAccessException {
		return discreDao.findCountDiscreDao(paramsMap);
	}

	@Override
	public int delforUpdateDiscreService(Map<String, Object> InvestigInfo) throws DataAccessException {
		return discreDao.delforUpdateDiscreDao(InvestigInfo);
	}

	@Override
	public List<Map<String, Object>> findDiscreByCodeTypeService(Map<String, Object> paramsMap)
			throws DataAccessException {
		return discreDao.findDiscreByCodeTypeDao(paramsMap);
	}

	@Override
	public int findSonDiscre(Map<String, Object> paramsMap) throws DataAccessException {
		// TODO Auto-generated method stub
		return discreDao.findSonDiscre(paramsMap);
	}

	
	


	
}
